package com.yf.controller.admin;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import com.yf.entity.AccountTransferEntity;
import com.yf.service.AccountTransferService;
import com.yf.response.R;
import com.yf.consts.DaoConst;


/**
 * 转账Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Thu Aug 16 13:36:44 CST 2018
 */
@RestController
@RequestMapping("/accounttransfer")
public class AccountTransferController {
    @Autowired
    private AccountTransferService accountTransferService;

    /**
     * 列表转账
     */
    @RequestMapping("/list")
    @RequiresPermissions("accounttransfer:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<AccountTransferEntity> accountTransferList = accountTransferService.queryList(params);
        return R.ok(new PageInfo(accountTransferList));
    }

    /**
     * 查看转账
     */
    @SysLog("查看转账")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("accounttransfer:info")
    public R info(@PathVariable("id") Long id) {
        AccountTransferEntity accountTransfer = accountTransferService.get(id);

        return R.ok(accountTransfer);
    }

    /**
     * 保存转账
     */
    @SysLog("保存转账")
    @RequestMapping("/save")
    @RequiresPermissions("accounttransfer:save")
    public R save(AccountTransferEntity accountTransfer) {
        accountTransferService.save(accountTransfer);

        return R.ok(accountTransfer);
    }

    /**
     * 修改转账
     */
    @SysLog("修改转账")
    @RequestMapping("/update")
    @RequiresPermissions("accounttransfer:update")
    public R update(AccountTransferEntity accountTransfer) {
        accountTransferService.update(accountTransfer);

        return R.ok(accountTransfer);
    }

    /**
     * 删除转账
     */
    @SysLog("删除转账")
    @RequestMapping("/delete")
    @RequiresPermissions("accounttransfer:delete")
    public R delete(@RequestBody Long[]ids) {
        accountTransferService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有转账
     */
    @SysLog("所有转账")
    @RequestMapping("/queryAll")
    public R queryAll(@RequestParam Map<String, Object> params) {

        List<AccountTransferEntity> accountTransferList = accountTransferService.queryList(params);

        return R.ok(accountTransferList);
    }

    /***********自定义开始***********/
}
